<html>
<head>
<script type="text/javascript" src="/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="/js/jquery-form.js"></script>
<script type="text/javascript">
 $(document).ready(
  function(){
	 /*  $("#btn1").click(function(){
		  $.ajax(
					type:"post",
					url:"/login"
					data:$('loginForm').serialize(),
					async:false,
					error:function(request){
						alert("connection erro");
					},
					success:function(data){
						alert("success");
					}
					 );
	  }); */
	  
	/*   $('#loginForm').submit(function() { 
          $(this).ajaxSubmit(function() {   
        	      alert("success！");
                  $('#output1').html("提交成功！欢迎下次再来！").show();    
          }); 
             return false; //阻止表单默认提交
   });   */
	   
	  $("#btn1").click(
		function (){
			alert($('#loginForm').serializeArray());
			var data = getFormJson('#loginForm');
			var data = $('#loginForm').serializeArray();
			    $.ajax(
						type:"post",
						url:"/login",
						data:data,
						async:false,
						cache:false,
						dataType:"json",
						error:function(request){
							alert("connection erro");
						},
						success:function(data){
							alert("success");
						}
						 ); 
						 
						
		}	  
	  ); 
	  
	  //获取表单数据
	   function getFormJson(frm) {  //frm：form表单的id  
	      var o = {};    
	      var a = $("#"+frm).serializeArray();    
	      $.each(a, function() {    
	          if (o[this.name] !== undefined) {    
	              if (!o[this.name].push) {    
	                  o[this.name] = [ o[this.name] ];    
	              }    
	              o[this.name].push(this.value || '');    
	          } else {    
	              o[this.name] = this.value || '';    
	          }    
	      });    
	      return o;    
	  } 
} 
 );
</script>
</head>
<body>
              <div><h1>用户系统</h1>
              <div>
              <form id="loginForm" method="post" action="/login">
                 userName：<input type="text" name="userName" value="jimTina"/></br>
                 passWord：<input type="password" name="passWord" value="314159"/></br>
                 <input type="submit" id="test" value="提交" /> <br/>
                 <div id="output1" style="display:none;"></div>
                 <button id="btn1">登陆系统</button>
                <!--  <input type="submit" value="登陆系统"/> -->
              </form>
              </div>
              </div>
</body>
</html>